package com.yh.servlet.admin;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.yh.entity.Zhanfeng;
import com.yh.service.UserService;
import com.yh.service.impl.UserServiceImpl;

@WebServlet("/admin/user-update-form.let")
public class UserUpdateFormServlet extends HttpServlet{
	
	private Logger log = LoggerFactory.getLogger(UserUpdateFormServlet.class);
	private UserService userService = new UserServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		try {
			Integer userId = Integer.valueOf(req.getParameter("userId"));
			Zhanfeng user = userService.Get(userId);
			req.setAttribute("user", user);
//			System.out.println(user);
			log.debug("user:{}",user);
		} catch (Exception e) {
			throw new ServletException("参数错误",e);
		}
		req.getRequestDispatcher("/admin/user-update-form.jsp").forward(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}
